package com.force.langchain4j.vstore.impl;

import com.force.langchain4j.vstore.VectorStoreService;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.ConnectParam;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

@Component
public class VectorStoreServiceImpl implements VectorStoreService {

	private MilvusServiceClient milvusServiceClient;

	@Override
	public void createSchema(final String kid, final String modelName) {
		milvusServiceClient = new MilvusServiceClient(
				ConnectParam.newBuilder()
						.withHost("47.98.126.125")
						.withPort(19530)
						.withAuthorization("root")
						.withAuthorization("root", "sxq123")
						.build());

	}

	@Override
	public void removeById(final String id, final String modelName) {

	}


	/**
	 * 获取向量模型
	 */
	@SneakyThrows
	public static EmbeddingModel getEmbeddingModel(String modelName, String apiKey, String baseUrl) {
		EmbeddingModel embeddingModel;
//		if ("quentinz/bge-large-zh-v1.5".contains(modelName)) {
//			embeddingModel = OllamaEmbeddingModel.builder()
//					.baseUrl(baseUrl)
//					.modelName(modelName)
//					.build();
//		} else if ("baai/bge-m3".contains(modelName)) {
			embeddingModel = OpenAiEmbeddingModel.builder()
					.apiKey(apiKey)
					.baseUrl(baseUrl)
					.modelName("BAAI/bge-m3")
					.build();
//		} else {
//			throw new ServiceException("未找到对应向量化模型!");
//		}
		return embeddingModel;
	}

}
